package com.binyouwei.designpatterns.creation_type.singleton;

/**
 * @author 宾有为
 * @date 2024/6/20 20:09
 * @link https://blog.csdn.net/baidu_41616022?type=blog
 * @describe：单例模式 —— 饿汉式
 * 优点：没有加锁，执行效率会提高。
 * 缺点：类加载时就初始化，浪费内存。
 **/
public class EagerInitialization {
    private static final EagerInitialization instance = new EagerInitialization();

    private EagerInitialization() {}

    public static EagerInitialization getInstance() {
        return instance;
    }

    public void print() {
        System.out.println("Eager Initialization");
    }
}
